package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.OrrMaterialCalibrationDetailService;
import com.yunhai.model.entity.orr.OrrMaterialCalibrationDetailEntity;
import com.yunhai.model.vo.orr.OrrMaterialCalibrationDetailQuery;
import com.yunhai.model.vo.orr.OrrMaterialCalibrationDetailVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/orrMaterialCalibrationDetail")
public class OrrMaterialCalibrationDetailController {

	@Resource
	private OrrMaterialCalibrationDetailService orrMaterialCalibrationDetailService;


	/**
	 * 获取 OrrMaterialCalibrationDetail 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getOrrMaterialCalibrationDetailPagination(PaginationVo paginationVo, OrrMaterialCalibrationDetailQuery orrMaterialCalibrationDetailQuery ) throws Exception {
		IPage page = orrMaterialCalibrationDetailService.getOrrMaterialCalibrationDetailPagination(paginationVo, orrMaterialCalibrationDetailQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 OrrMaterialCalibrationDetail 所有数据
	 */
	@GetMapping("/allList")
	public Ret getOrrMaterialCalibrationDetailAllList( OrrMaterialCalibrationDetailQuery orrMaterialCalibrationDetailQuery ) throws Exception {
		List<OrrMaterialCalibrationDetailEntity> list = orrMaterialCalibrationDetailService.getOrrMaterialCalibrationDetailAllList( orrMaterialCalibrationDetailQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 OrrMaterialCalibrationDetail 详情
	 */
	@GetMapping("/{id}")
	public Ret getOrrMaterialCalibrationDetailDetailById(@PathVariable Long id) throws Exception {

	    OrrMaterialCalibrationDetailEntity orrMaterialCalibrationDetailEntity = orrMaterialCalibrationDetailService.getOrrMaterialCalibrationDetailDetail(id);
		return Ret.ok(orrMaterialCalibrationDetailEntity);
	}


	/**
	 * 新增 OrrMaterialCalibrationDetail
	 * */
	@PostMapping("")
	public Ret addOrrMaterialCalibrationDetail(@RequestBody OrrMaterialCalibrationDetailVo orrMaterialCalibrationDetailVo) throws Exception {

		orrMaterialCalibrationDetailService.addOrrMaterialCalibrationDetail(orrMaterialCalibrationDetailVo);
		return Ret.ok();
	}


	/**
	 * 更新 OrrMaterialCalibrationDetail
	 * */
	@PutMapping("")
	public Ret updateOrrMaterialCalibrationDetail(@RequestBody OrrMaterialCalibrationDetailVo orrMaterialCalibrationDetailVo) throws Exception {

		orrMaterialCalibrationDetailService.updateOrrMaterialCalibrationDetail(orrMaterialCalibrationDetailVo);
		return Ret.ok();
	}


	/**
	 * 删除 OrrMaterialCalibrationDetail
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveOrrMaterialCalibrationDetail( @RequestBody List<Long> ids ) throws Exception {

	    orrMaterialCalibrationDetailService.batchRemoveOrrMaterialCalibrationDetail(ids);
		return Ret.ok();
	}
}
